import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:live_music/components/ui/theme.dart';
import 'package:live_music/event/momonEvent.dart';
import 'package:live_music/models/topic_detail_model.dart';
import 'package:live_music/pages/topic/topic_detail.dart';
import 'package:live_music/utils/cgq_utils.dart';
import 'package:live_music/utils/eventBusUtils.dart';

class TopicCardPublish extends StatefulWidget {
  TopicCardPublish({Key key, this.topicItem}) : super(key: key);
  TopicDetailModel topicItem;
  @override
  _TopicCardPublishState createState() => _TopicCardPublishState();
}

class _TopicCardPublishState extends State<TopicCardPublish>
    with SingleTickerProviderStateMixin {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: () {
          EventBusUtils.getInstance()
              .fire(SelectTopicPublishEvent("#" + widget.topicItem.name));
          Get.back();
        },
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 0),
          margin: const EdgeInsets.only(top: 0),
          child: Card(
              child: ClipRRect(
            borderRadius: BorderRadius.circular(6),
            child: Stack(
              children: [
                SizedBox(
                  width: double.infinity,
                  height: double.infinity,
                  child: CgqUtils.imageCache(widget.topicItem.coverUrl,
                      fit: BoxFit.cover),
                ),
                Positioned(
                  child: Container(
                    color: Colors.black.withOpacity(.15),
                  ),
                ),
                Center(
                  child: Text(
                    '#' + widget.topicItem.name + '#',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: WcaoTheme.fsXl,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                Positioned(
                  bottom: 0,
                  child: Padding(
                    padding:
                        const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          margin: const EdgeInsets.only(top: 4),
                          child: Text(
                            "创建人  @" + widget.topicItem.createUserName,
                            style: const TextStyle(
                              color: Colors.white,
                            ),
                          ),
                        ),
                        Container(
                          margin: const EdgeInsets.only(top: 4),
                          child: Text(
                            widget.topicItem.momentCount.toString() +
                                "个讨论" +
                                "  @" +
                                widget.topicItem.lastUpdateUserName,
                            style: const TextStyle(
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                )
              ],
            ),
          )),
        ));
  }
}
